//
//  WCBAddressCell.m
//  WeChatBuniess
//
//  Created by Guo Rui on 2017/12/19.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "WCBAddressCell.h"

@interface WCBAddressCell()
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *nameLabel;
@property (strong, nonatomic) UILabel *phoneLabel;
@property (strong, nonatomic) UILabel *addressLabel;
@end

@implementation WCBAddressCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat x, y, w, h;
    CGFloat width = CGRectGetWidth(self.contentView.frame);
    
    {
        x = 30.f;
        y = 15.f;
        w = width - 2 * x;
        h = 45.f;
        self.titleLabel.frame = CGRectMake(x, y, w, h);
    }
    
    {
        x = 30.f;
        y = CGRectGetMaxY(self.titleLabel.frame) + 10.f;
        w = width - 2 * x;
        h = 40.f;
        self.nameLabel.frame = CGRectMake(x, y, w, h);
    }
    
    {
        x = 30.f;
        y = CGRectGetMaxY(self.nameLabel.frame) + 10.f;
        w = width - 2 * x;
        h = 40.f;
        self.phoneLabel.frame = CGRectMake(x, y, w, h);
    }
    
    {
        x = 30.f;
        y = CGRectGetMaxY(self.phoneLabel.frame) + 10.f;
        w = width - 2 * x;
        h = 40.f;
        self.addressLabel.frame = CGRectMake(x, y, w, h);
    }
    
}

#pragma mark - Public
- (void)setAddressModel:(WCBAdressModel *)addressModel
{
    _addressModel = addressModel;
    
    self.nameLabel.text = [NSString stringWithFormat:@"姓名: %@", addressModel.contacts];
    self.phoneLabel.text = [NSString stringWithFormat:@"电话: %@", addressModel.contactsPhone];
    self.addressLabel.text = [NSString stringWithFormat:@"地址: %@", addressModel.addressDesc];
}

#pragma mark - Getter
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor blackColor];
        _titleLabel.font = [UIFont systemFontOfSize:25];
        _titleLabel.text = @"寄送地址";
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = [UIColor colorWithRed:0.20 green:0.20 blue:0.20 alpha:1.00];
        _nameLabel.font = [UIFont systemFontOfSize:23];
        [self.contentView addSubview:_nameLabel];
    }
    return _nameLabel;
}

- (UILabel *)phoneLabel
{
    if (!_phoneLabel) {
        _phoneLabel = [[UILabel alloc] init];
        _phoneLabel.textColor = [UIColor colorWithRed:0.20 green:0.20 blue:0.20 alpha:1.00];
        _phoneLabel.font = [UIFont systemFontOfSize:23];
        [self.contentView addSubview:_phoneLabel];
    }
    return _phoneLabel;
}

- (UILabel *)addressLabel
{
    if (!_addressLabel) {
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.textColor = [UIColor colorWithRed:0.20 green:0.20 blue:0.20 alpha:1.00];
        _addressLabel.font = [UIFont systemFontOfSize:23];
        _addressLabel.numberOfLines = 0;
        [self.contentView addSubview:_addressLabel];
    }
    return _addressLabel;
}
@end
